package n_swing_jtable;

import java.util.Comparator;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableColumnModel;

public class TableTestModel3 extends AbstractTableModel{
	Object data[][] = {
			{"Nari","김씨", new Integer(123), "서울"},
			{"One", "이씨", new Integer(1111), "부산"},
			{"Two", "박씨", new Integer(2222), "대구"},
			{"Three", "홍씨", new Integer(3333), "인천"},
	};
	
	String name[] = {"아이디","성명","연락처","관광지"};
	
	/**
	 * This method initializes 
	 * 
	 */
	public TableTestModel3() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
			
	}

	@Override
	public int getRowCount() {
		// TODO Auto-generated method stub
		return data.length;
	}

	@Override
	public int getColumnCount() {
		// TODO Auto-generated method stub
		return name.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		// TODO Auto-generated method stub
		return data[rowIndex][columnIndex];
		
	}
	
	// 첫번째 컬럼이 아니면 수정 가능
	public boolean isCellEditable(int r, int c){
		return (c != 0)? true:false;
	}
	
	public String getColumnName(int c){
		return name[c];
	}
	
	public void setValueAt(Object obj, int r, int c){
		data[r][c] = obj;
	}


}
